<template>
  <div>
    <el-table
      :data="
        tableData.filter(
          (data) =>
            !search || data.name.toLowerCase().includes(search.toLowerCase())
        )
      "
      style="width: 100%"
    >
      <div class="card" />
      <div class="main_body">
        <div class="header" />
        <el-table-column label="#" fixed type="index" />
        <el-table-column label="用户名" prop="date" />
        <el-table-column label="昵称" prop="date" />
        <el-table-column label="头像" prop="name" />
        <el-table-column label="角色" prop="name" />
        <el-table-column label="添加时间" prop="name" />
        <el-table-column label="操作" align="right">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </div>
    </el-table>
  </div>
</template>

<script>
import { findAllRoles } from '@/api/authority/account'
export default {
  data() {
    return {
      tableData: [],
      search: ''
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      findAllRoles().then((res) => {
        console.log(res)
        this.tableData = res.data.items
      })
    },
    handleEdit(index, row) {
      console.log(index, row)
    },
    handleDelete(index, row) {
      console.log(index, row)
    }
  }
}
</script>

<style>
</style>
